#pragma once
/*!
* \file  ui_layouts.h
* \brief Layouts
* 
*
* 
* \author patdz@qq.com
* \version 1.0
* \date 2014/06/11
*/
#include "ui_control.h"

_SSL_BEGIN
_SSUIL_BEGIN

#pragma warning(push)
#pragma warning(disable:4250)

class SSUI_CLASS UILayout :
	public UIControl
{
public:
	UILayout();
	virtual ~UILayout();

public:
	virtual bool ApplyAttributes(IUIBuilderInterface *ui_builder, 
		IUIXMLDocumentInterface *xml_document, UIXmlNode node);

public:
	void SetIgnoreInvisibleControlsOnLayout(bool flag);

protected:
	bool ignore_invisible_controls_on_layout_;
};

class SSUI_CLASS UIHorizontalLayout :
	public UILayout
{
public:
	UIHorizontalLayout();
	virtual ~UIHorizontalLayout();

	//
protected:
	virtual void OnRecalcChildsLayoutOnVisibleSizeChanged();

	// UIControl
protected:
	virtual UIRect GetChildsRect();

	//
protected:
	void SetItemPosition(
		IUIControlInterface *item,
		int &xoffset,
		const UIRect &client_rt,
		IUIControlInterface *expand_control,
		int expand_control_width
		);
};


class SSUI_CLASS UIVerticalLayout :
	public UILayout
{
public:
	UIVerticalLayout();
	virtual ~UIVerticalLayout();

	//
protected:
	virtual void OnRecalcChildsLayoutOnVisibleSizeChanged();

	// UIControl
protected:
	virtual UIRect GetChildsRect();

	//
protected:
	void SetItemPosition(
		IUIControlInterface *item,
		int &yoffset,
		const UIRect &client_rt,
		IUIControlInterface *expand_control,
		int expand_control_height
		);
};

class SSUI_CLASS UIFlowLayout :
	public UILayout
{
public:
	UIFlowLayout();
	virtual ~UIFlowLayout();

protected:
	virtual void OnRecalcChildsLayoutOnVisibleSizeChanged();

protected:
	bool CalcALine(
		ss_in_ int width,
		ss_out_ int &height,
		ss_in_ int index_b,
		ss_out_ int &index_e
		);
};

#pragma warning(pop)

_SSUIL_END
_SSL_END
